import less from 'rollup-plugin-less';
import pkg from './package.json';
import commonjs from '@rollup/plugin-commonjs';
import { terser } from 'rollup-plugin-terser';
import resolve from 'rollup-plugin-node-resolve';
import vue from 'rollup-plugin-vue';
import babel from 'rollup-plugin-babel';
import copy from 'rollup-plugin-copy'
// 轻量级组件开发
export default{
     input:'./packages/index.js',
     output:[
         {
            file:'./lib/components.min.js' ,
            format: 'cjs', // 标签导入
            name: 'files',
          },
          {
            file:'./lib/components.umd.js' ,
            format: 'umd',  // 适合script标签导入
            name: 'files',
          },
          {
            file:'./lib/components.esm.js' ,
            format: 'esm',  // 适合es6模块导入
            name: 'files',
          }
     
     ],
     plugins:[
        copy({
          targets: [
            { src:'./packages/index.js', dest: './lib/' }
          ]
        }),
        vue({
            css: true,  // css样式一同处理
            
            compileTemplate: true,
          }), 
    
        //解决第三方依赖打包问题
        resolve({
            extensions: ['.vue'],
            exclude: '**/node_modules/**'
        }),
         // commonjs 语法模块
        commonjs(),
        babel({  // 排除node_modules
            exclude: 'node_modules/**'
          }),
        //  使用less 配置 在组件less 区域不能出现注释
        less(
          {
              output:'./lib/style.css'
          } 
      ),  
     
      terser()
     ],
     globals: {
        vue: 'Vue',
      },
    inlineDynamicImports: true
}
